package com.shop.shopserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.shoppojo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户id查询权限
     * @param userId
     * @return
     */
    @Select("SELECT \n" +
            "    p.authority \n" +
            "FROM \n" +
            "    user_priv up\n" +
            "JOIN \n" +
            "    priv p ON p.id = up.priv_id\n" +
            "WHERE \n" +
            "    up.user_id = 1;")
    List<String> findPrivilegesByUserId(Long userId);

   void insertUser(User user);

}
